<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>填写银行信息</title>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<link rel="stylesheet" type="text/css" href="css/larea.css"/>
	</head>
	<style type="text/css">
		/*移动端1px下边线*/
		.border{ position: relative; }
		.border:after{ content: ''; display:block; position: absolute; width: 100%; left: 0px; bottom: 0px;height: 1px; background-color:  #efefef; -webkit-transform: scaleY(0.5); transform: scaleY(0.5);}
		.lable{height: 0.88rem;font-size: 0.28rem;padding-left: 0.4rem;}
		.item{height: 1.1rem;background: #fff;font-size: 0.3rem;font-weight: bold;}
		.item p{margin-left: 0.4rem;}
		.item input{margin-left: 0.5rem;font-size: 0.3rem;}
		.confirm{height: 0.88rem;width: 6.8rem;margin: 0.52rem auto;font-size: 0.3rem;background: #0D6FB8;border-radius: 5px;color: #fff;cursor: pointer;}
	</style>
	<body>
		<!--头部header开始-->
		<header class="flex flex-align-center">
			<div class="left flex flex-align-center" onclick="Util.back()">
				<img src="img/arrleft.png" alt="" class="arrleft"/>
			</div>
			<div class="title">填写银行信息</div>
			<div class="right flex flex-pack-center flex-align-center">
			</div>
		</header><!--头部header结束-->
		<!--内容部分开始-->
		<div class="container">
			<div class="lable flex flex-align-center"><p>请选择开户银行</p></div>
			<div class="item flex flex-align-center">
				<p>开户银行：</p>
				<input type="text"  placeholder="请输入开户银行" readOnly='readOnly' id='shortName'/>
			</div>
			<div class="lable flex flex-align-center"><p>请选择开户城市</p></div>
			<div class="item flex flex-align-center">
				<p>开户城市：</p>
				<input type="text" readOnly='readOnly' placeholder="请输入开户城市" id="bankCity"/>
				<input id="bankCitykey" readonly="" type="hidden" value=""/>
			</div>
			<div class="lable flex flex-align-center"><p>请选择开户支行</p></div>
			<div class="item flex flex-align-center border">
				<p>开户支行：</p>
				<input type="text"  placeholder="请输入支行地址" readOnly='readOnly' id="bankzName" onclick="Auth.Authjump()"/>
			</div>
			<div class="item flex flex-align-center">
				<p>手机号：</p>
				<input type="text" id = "phone"  placeholder="请输入银行预留手机号"/>
			</div>
			<div class="confirm flex flex-align-center flex-pack-center"><p>提交</p></div>
		</div><!--内容部分结束-->
	</body>
	<script type="text/javascript" src="js/rem.js"></script>
	<script type="text/javascript" src="js/zepto.js"></script>
	<script type="text/javascript" src="js/template.js"></script>
	<script type="text/javascript" src="js/layer.js"></script>
	<script type="text/javascript" src="js/api.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="js/larea.js"></script>
	<script type="text/javascript">
		$('#shortName').val(localStorage.shortName);
		$('#bankzName').val(localStorage.branchName);
		$('#bankCity').val(sessionStorage.bankCity); //取出缓存开户城市
		$('#bankCitykey').val(sessionStorage.bankCitykey); //取出缓存开户城市code
		Public.areaMap(function(root){
			//城市三级联动
		 var areaBankOpen = new LArea();
		 areaBankOpen.init({
		        'trigger': '#bankCity', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
		        'valueTo': '#bankCitykey', //选择完毕后id属性输出到该位置
		        'keys': {
		            id: 'code',
		            name: 'name'
		        }, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
		        'type': 1, //数据源类型
		        'data': root //数据源
		    });
		});
		$('.confirm').click(function(){ //确认提交
		var accName = localStorage.userName; //持卡人姓名
		var accNo = localStorage.acctNo; //结算卡卡号
		var bankName = $('#shortName').val(); //结算卡开户行
		var bankCity = $('#bankCity').val(); //开户城市
		var bankCitykey = $('#bankCitykey').val(); //开户城市代码
		var bankzName = $('#bankzName').val(); //开户支行名
		var phoneNo = $('#phone').val(); //预留手机号码
		if(accName == ''){
				layer.open({
					content: '先实名认证后，方可信用卡认证',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
		}else if(accNo.length<16 || accNo == ''){
			layer.open({
				content: '卡号至少16位',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
		}else if(bankCity == ''){
			layer.open({
				content: '开户城市不能为空',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
		}else if(bankzName == ''){
			layer.open({
				content: '开户支行不能为空',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
		}else if(!phoneNo.match(/^(1)[0-9]{10}$/)){
			layer.open({
				content: '预留手机号不合法',
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
		}else{
			Public.settleCardAuth({
				userId: localStorage.userId, //用户userId
				customerName: accName, //持卡人姓名
				certId: localStorage.cardNo, //身份证号码
				bankId: localStorage.bankId, //银行id
				bankName: bankName, //银行名称
				subBankName: bankzName, //支行名称
				acctNo: accNo, //银行卡号
				phoneNo: phoneNo, //预留手机号
				areaCodes: bankCitykey, //开户城市编码
				areaNames: bankCity, //开户城市
				accountType: 2
			},function(res){
				layer.open({
					content:'结算卡认证提交成功!',
							skin: 'msg',
							time: 2 //2秒后自动关闭
					});
			});
		}	
		});
	</script>
</html>
